package com.five.admin.controller;

import com.five.controller.BaseController;
import com.five.admin.service.OrdersService;
import com.five.entity.CourseClassify;
import com.five.entity.Orders;
import com.five.vo.BaseResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: star
 * @Date: 2021-05-21 14:27
 * 订单 Controller层
 */
@Controller
@RequestMapping("order")
@CrossOrigin
@Api("订单业务接口")
public class OrdersController extends BaseController {

    @Autowired
    private OrdersService ordersService;

    /**
     * @return订单列表
     */
    @ResponseBody
    @RequestMapping(value = "getOrder",method = RequestMethod.GET)
    @ApiOperation("获取订单列表接口")
    public BaseResultVO getCourseClassify(String orderCode,Integer page){
        List<Orders> list = ordersService.fuzzyQueryById(orderCode,page);
        int pages = ((ordersService.countOrder(orderCode)-1)/8)+1;
        Map<String,Object> resultMap = new HashMap();
        resultMap.put("pages",pages);
        resultMap.put("orderList",list);
        return successResp(resultMap);
    }

    /**
     * @return订单列表
     */
    @ResponseBody
    @RequestMapping(value = "fuzzyQueryOrder",method = RequestMethod.GET)
    @ApiOperation("模糊查询订单信息")
    public BaseResultVO fuzzyQueryCourseClassify(String orderCode,int page){
        List<Orders> list = ordersService.fuzzyQueryById(orderCode,page);
        return successResp(list);
    }
}
